package com.zf.shuashua.ui.game;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import com.zf.shuashua.R;
import com.zf.shuashua.base.BaseFragment;

public class GameFragment extends BaseFragment{

    private GameWelfareFragment gameWelfareFragment;
    private boolean isFirst;

    public static GameFragment newInstance() {
        Bundle args = new Bundle();
        GameFragment fragment = new GameFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initView(View rootView) {
        isFirst = true;
        if (findFragment(GameWelfareFragment.class) == null) {
            gameWelfareFragment = GameWelfareFragment.newInstance();
            loadRootFragment(R.id.fl_container, gameWelfareFragment);
        }
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            if (gameWelfareFragment != null && !isFirst) {
                gameWelfareFragment.reload(); // 刷新
            } else {
                isFirst = false;
            }
        }
    }

    public boolean isShowPopup(){
        if(gameWelfareFragment == null){
            return false;
        }
        return gameWelfareFragment.isShowPopup();
    }

    @Override
    protected void initViewModel() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_game;
    }

}
